
package com.ssm.service.impl;

import com.ssm.dao.AdminMapper;
import com.ssm.dao.UmAdminMapper;
import com.ssm.entity.Admin;
import com.ssm.entity.UmAdmin;
import com.ssm.entity.UmAdminExample;
import com.ssm.service.AdminService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("adminService")
public class AdminServiceImpl implements AdminService {

    @Resource(name = "adminMapper")
    private AdminMapper adminMapper;
    @Resource(name = "umAdminMapper")
    private UmAdminMapper umAdminMapper;
    @Override
    public Admin login(String username, String password) {
        return adminMapper.selectByLogin(username,password);
    }

    public List<UmAdmin> listAllAdmin() {
        return umAdminMapper.selectByExample(new UmAdminExample());
    }

    public Integer createAdmin(UmAdmin umAdmin) {
        return umAdminMapper.insertSelective(umAdmin);
    }
    @Override
    public Integer update(UmAdmin umAdmin) {
        return umAdminMapper.updateByPrimaryKeySelective(umAdmin);
    }
    public Integer deleteAdmin(int adminid) {
        return umAdminMapper.deleteByPrimaryKey(adminid);
    }
    public UmAdmin getUmAdmin(int adminid) {
        return umAdminMapper.selectByPrimaryKey(adminid);
    }

}
